^[ and all
of the escape sequencesPress the uppercase J.
:gDelete all lines matching a pattern.
:g/pattern/d
Delete all lines that do not match a pattern.
:g!/pattern/d
:v/pattern/d
Delete all blank lines (^ is start of line;
\s* is zero or more whitespace characters; $
is end of line).
:g/^\s*$/d
zo: open the fold under the current cursorzO: Open the folds throughout the whole bufferzc: close the fold under the current cursorzC: Close the folds throughout the whole bufferza: toggle the folding under the current cursorzA: Toggle the folding throughout the whole bufferzr: reduce the folding by opening one more level of
folds throughout the whole bufferzR: Reduce the folding by opening all levels of folds
throughout the whole bufferzm: give more folding by closing one more level of
folds throughout the whole bufferzM: Give more folding by closing all levels of folds
throughout the whole bufferSometimes the syntax highlighting is broken. Use
:syntax sync fromstart to fix it.
Use :retab.
:376,549s/\\<abc\\>/edf/gNormally do as follows,
:%s/\\<abs\\>/bng/gHowever, typing \\< \\> each time is tedious.
Since my vimrc file highlights the word where the cursor
locates, I can directly run the following command when the cursor is at
abs.
:%s//bng/gFor example, I have
abc
def
ghi
and
123
456
789
and I want
123 abc
456 def
789 ghi
The solution is: Use visual block (ctrl-v) to cut the letter column. Then move to the first line of the number column. Move to the end and make one space. Then paste the letter column.
CTRL-R {register} pastes things in the insert mode. For
example, CTRL-R * will insert in the contents of the
clipboard and CTRL-R " (the unnamed register) inserts the
the last delete or yank.
q in the normal mode
a: press
qa.q.9@a^[ and
all of the escape sequencesThe escape sequences are ASCII escape sequences which could be used to render colored text in the terminal.
Using keyboard entry:
sed 's/[Ctrl-v][Esc]//g'
alternatively
sed 's/[Ctrl-v][Ctrl-[]//g'
where [Ctrl-v] is the key Ctrl + key
v.
Use :read. For example, :read !pwd.
Enable spellcheck for Chinese
set spell spelllang=en_us,cjk
set ff=unix
set encoding=utf-8 " The encoding displayed.
set fileencoding=utf-8 " The encoding written to file.
set autoread
set belloff=all
<>:set matchpairs+=<:>
vim --startuptime timeCost.txt timeCost.txt
This behavior occurs on my work machine, an old version of debian. I cannot upgrade the system. Therefore I googled and found the solution.
It is caused by the backupcopy feature of Vim. The simple solution is
set backupcopy=yes
Reference: link.
vim 8.2 includes a default _gvimrc that has a “set nice
colors” (hah) block of highlight commands in it. Create a blank
.gvimrc in the home directory, and that fixes the problem.
I’m installing vim with scoop in case that matters.